package com.mall.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.mall.common.annotation.Log;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.enums.BusinessType;
import com.mall.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mall.business.domain.TProductUserMoney;
import com.mall.business.service.ITProductUserMoneyService;
import com.mall.common.core.page.TableDataInfo;

/**
 * 一客一价Controller
 *
 * @author ruoyi
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/business/productusermoney")
public class TProductUserMoneyController extends BaseController {
    @Autowired
    private ITProductUserMoneyService tProductUserMoneyService;

    /**
     * 查询一客一价列表
     */
//@RequiresPermissions("business:productusermoney:list")
    @GetMapping("/list")
    public TableDataInfo list(TProductUserMoney tProductUserMoney) {
        startPage();
        List<TProductUserMoney> list = tProductUserMoneyService.selectTProductUserMoneyList(tProductUserMoney);
        return getDataTable(list);
    }

    /**
     * 导出一客一价列表
     */
    //@RequiresPermissions("business:productusermoney:export")
    @Log(title = "一客一价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProductUserMoney tProductUserMoney) {
        List<TProductUserMoney> list = tProductUserMoneyService.selectTProductUserMoneyList(tProductUserMoney);
        ExcelUtil<TProductUserMoney> util = new ExcelUtil<TProductUserMoney>(TProductUserMoney.class);
        util.exportExcel(response, list, "一客一价数据");
    }

    /**
     * 获取一客一价详细信息
     */
    //@RequiresPermissions("business:productusermoney:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tProductUserMoneyService.selectTProductUserMoneyById(id));
    }

    /**
     * 新增一客一价
     */
    //@RequiresPermissions("business:productusermoney:add")
    @Log(title = "一客一价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated  @RequestBody TProductUserMoney tProductUserMoney) {
        return toAjax(tProductUserMoneyService.save(tProductUserMoney));
    }

    /**
     * 修改一客一价
     */
    //@RequiresPermissions("business:productusermoney:edit")
    @Log(title = "一客一价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated  @RequestBody TProductUserMoney tProductUserMoney) {
        return toAjax(tProductUserMoneyService.updateById(tProductUserMoney));
    }

    /**
     * 删除一客一价
     */
    //@RequiresPermissions("business:productusermoney:remove")
    @Log(title = "一客一价", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tProductUserMoneyService.removeByIds(Arrays.asList(ids)));
    }
}
